package 笔试.农银经科;

import java.util.ArrayList;

public class Solution
{
    public static void main(String[] args)
    {
        System.out.println(method(2, 8));
    }
    public static int method(int n,int m)
    {
        char[] symbols={'+','-','*','/'};
        ArrayList<Integer> list = new ArrayList<>();
        for (int i = 0; i < symbols.length; i++)
        {
            for (int j = 0; j < symbols.length; j++)
            {
                for (int k = 0; k < symbols.length; k++)
                {
                    list.add(calculate(symbols[k],
                            calculate(symbols[j],
                                    calculate(symbols[i],n,n),n),n));
                }
            }
        }
        for (int i = 0; i < list.size(); i++)
        {
            if (m==list.get(i))
                return 1;
        }
        return 0;
    }
    public static int calculate(char c,int num1,int num2)
    {
        if (c=='+')
            return num1+num2;
        else if (c=='-')
            return num1-num2;
        else if (c=='*')
            return num1*num2;
        else
            return num1/num2;
    }

}
